package com.acheli.registry.entity;

import com.acheli.ACHeli;
import com.acheli.registry.factories.ACHFactories;
import com.acheli.rideable.entites.RideableEntity;
import com.acheli.rideable.entites.ComponentEntity;
import com.acheli.rideable.factory.ACHeliEntitiesFactory;
import com.acheli.rideable.functionLathes.RideableFL;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.Level;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;

import java.util.Objects;

public class ACHEntities {
    public static DeferredRegister<EntityType<?>> ENTITY_TYPES
            = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, ACHeli.MODID);

    public static RegistryObject<EntityType<RideableEntity>> RIDEABLE_ENTITY_TYPE =
            ENTITY_TYPES.register("rideable_entity", () ->
                    EntityType.Builder.<RideableEntity>of(new EntityType.EntityFactory<RideableEntity>() {
                                @Override
                                public RideableEntity create(EntityType<RideableEntity> pEntityType, Level pLevel) {
                                    return new RideableEntity(pEntityType, pLevel);
                                }
                            }, MobCategory.MISC)
                            .sized(2.5f, 1.2f)  // 设置碰撞箱尺寸（宽度，高度）
                            .clientTrackingRange(10)  // 客户端追踪范围（区块数）
                            .setUpdateInterval(1)      // 数据同步间隔（tick）
                            .build(Objects.requireNonNull(ResourceLocation.tryBuild(ACHeli.MODID, "rideable_entity")).toString())
            );
    public static RegistryObject<EntityType<ComponentEntity>> RIDEABLE_COMPONENT_ENTITY_TYPE =
            ENTITY_TYPES.register("component_entity", () ->
                    EntityType.Builder.<ComponentEntity>of(new EntityType.EntityFactory<ComponentEntity>() {
                                @Override
                                public ComponentEntity create(EntityType<ComponentEntity> pEntityType, Level pLevel) {
                                    return new ComponentEntity(pEntityType, pLevel,null, null);
                                }
                            }, MobCategory.MISC)
                            .sized(1f, 1f)  // 设置碰撞箱尺寸（宽度，高度）
                            .clientTrackingRange(10)  // 客户端追踪范围（区块数）
                            .setUpdateInterval(3)      // 数据同步间隔（tick）
                            .build(Objects.requireNonNull(ResourceLocation.tryBuild(ACHeli.MODID, "component_entity")).toString())
            );

    public static void register(IEventBus eventBus) {
        ENTITY_TYPES.register(eventBus);
    }
}
